#include <bits/stdc++.h>

using namespace std;

class Solution {
public:
	vector<vector<int>> flipAndInvertImage(vector<vector<int>>& image)
	{
		int col_length = image[0].size(), odd = col_length & 1;
		for (auto& col : image) {
			auto endItr = --end(col);
			for_each_n(col.begin(), col_length >> 1, [&](auto& grid) { swap((grid = !grid), (*endItr = !(*endItr))); });
			if (odd) *endItr = !*endItr;
		}
		return image;
	}
};

int main()
{
	Solution solution;
	return 0;
}
